﻿
@{
    ViewBag.Title = "首页";
}
@section CSS{
    <link rel="stylesheet" href="~/Content/AdminLTE/plugins/jvectormap/jquery-jvectormap.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="~/Content/AdminLTE/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">


    <!-- Morris chart -->
    <link rel="stylesheet" href="~/Content/AdminLTE/plugins/morris.js/morris.css">
    <style>
        .mytable tr{height:41px;line-height:41px;}
        .handle{width:20px;text-align:center;}
    </style>
}
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                首页
                <small>&nbsp;</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                @*<li class="active"></li>*@
            </ol>
        </section>
        <section class="content" style="min-height:100px;">
            <div class="row">
                <div class="col-md-6 col-sm-6 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-green "><i class="ion ion-social-yen-outline"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">可提现金额</span>
                            <span class="info-box-number">@ViewBag.Balances.ToString("f2")<small>元</small></span>
                            @*可提现金额 <b>@ViewBag.Balance.ToString("f2")</b> <small>元</small>*@
                            @*<a href="/Finance/Withdrawal">去提现</a>*@
                        </div>
                        <!-- /.info-box-content -->
                    </div>
                    <!-- /.info-box -->
                </div>
                <!-- /.col -->

                <div class="col-md-6 col-sm-6 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-yellow"><i class="ion ion-ios-timer-outline"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">待结算</span>
                            <span class="info-box-number">@ViewBag.Settlementing.ToString("f2")<small>元</small></span>
                            @*<a href="/Finance/FinanceCheck">查看明细</a>*@

                        </div>
                        <!-- /.info-box-content -->
                    </div>
                    <!-- /.info-box -->
                </div>
                <!-- /.col -->
                <!-- fix for small devices only -->
                <div class="clearfix visible-sm-block"></div>
            </div>
            <div class="row">
                <div class="col-lg-3 col-xs-3">
                    <!-- small box -->
                    <div class="small-box bg-red">
                        <div class="inner">
                            <h3>@ViewBag.ShippingNumber</h3>
                            <p>待发货</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-android-bus"></i>
                        </div>
                        <a href="/Order/GoodsOrders?order_status=4" class="small-box-footer">详情 <i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <!-- ./col -->
                <div class="col-lg-3 col-xs-3">
                    <!-- small box -->
                    <div class="small-box bg-aqua">
                        <div class="inner">
                            <h3>@ViewBag.ReceivingNumber</h3>
                            <p>待收货</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-stats-bars"></i>
                        </div>
                        <a href="/Order/List?order_status=5" class="small-box-footer">详情 <i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <!-- ./col -->
                <div class="col-lg-3 col-xs-3">
                    <!-- small box -->
                    <div class="small-box bg-green">
                        <div class="inner">
                            <h3>@ViewBag.GoodsNumber1</h3>
                            <p>上架商品</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-bag"></i>
                        </div>
                        <a href="/goods/index/1" class="small-box-footer">详情 <i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <!-- ./col -->
    
            @*</div>
            <div class="row">*@
                <div class="col-lg-3 col-xs-3">
                    <!-- small box -->
                    <div class="small-box bg-yellow">
                        <div class="inner">
                            <h3>@ViewBag.GoodsNumber0</h3>
                            <p>下架商品</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-bag"></i>
                        </div>
                        <a href="/goods/index/3" class="small-box-footer">详情 <i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
            </div>
            <div class="row">

                <div class="col-xs-6">
                    <div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title">统计</h3>
                        </div>
                        <div class="box-body">
                            <table id="DataList" class="table table-bordered table-striped table-hover mytable">
                                <thead>
                                    <tr>
                                        <th>时间</th>
                                        <th>新增订单总额</th>
                                        <th>新增订单数量</th>
                                        <th>平均客单订单金额</th>
                                        <th>已完成订单金额</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @if (Model != null)
                                    {
                                    <tr>
                                        <td>今天</td>
                                        <td>@Model.today_order_total</td>
                                        <td>@Model.today_order_number</td>
                                        <td>@(Model.today_order_number > 0 ? (Model.today_order_total / Model.today_order_number).ToString("F2") : 0)</td>
                                        <td>@Model.today_order_money</td>
                                    </tr>
                                        @*<tr>
                                            <td>昨天</td>
                                            <td>@Model.yesterday_order_total</td>
                                            <td>@(Model.yesterday_order_number > 0 ? (Model.yesterday_order_total / Model.yesterday_order_number).ToString("F2") : 0)</td>
                                            <td>@Model.yesterday_order_number</td>
                                            <td>@Model.yesterday_order_money</td>
                                        </tr>*@
                                        <tr>
                                            <td>本周</td>
                                            <td>@Model.week_order_total</td>
                                            <td>@Model.week_order_number</td>
                                            <td>@(Model.week_order_number > 0 ? (Model.week_order_total / Model.week_order_number).ToString("F2") : 0)</td>
                                            <td>@Model.week_order_money</td>
                                        </tr>
                                        <tr>
                                            <td>本月</td>
                                            <td>@Model.month_order_total</td>
                                            <td>@Model.month_order_number</td>
                                            <td>@(Model.month_order_number > 0 ? (Model.month_order_total / Model.month_order_number).ToString("F2") : 0)</td>
                                            <td>@Model.month_order_money</td>
                                        </tr>
                                        <tr>
                                            <td>近7天</td>
                                            <td>@Model.seven_order_total</td>
                                            <td>@Model.seven_order_number</td>
                                            <td>@(Model.seven_order_number > 0 ? (Model.seven_order_total / Model.seven_order_number).ToString("F2") : 0)</td>
                                            <td>@Model.seven_order_money</td>
                                        </tr>
                                        <tr>
                                            <td>近30天</td>
                                            <td>@Model.thirty_order_total</td>
                                            <td>@Model.thirty_order_number</td>
                                            <td>@(Model.thirty_order_number > 0 ? (Model.thirty_order_total / Model.thirty_order_number).ToString("F2") : 0)</td>
                                            <td>@Model.thirty_order_money</td>
                                        </tr>
                                    }

                                </tbody>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <div class="col-xs-6">
                    <div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title">消息</h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <!-- See dist/js/pages/dashboard.js to activate the todoList plugin -->
                            <ul class="todo-list" id="news_list"></ul>
                        </div>

                        <!-- /.box-body -->
                    </div>
                </div>
                <!-- /.col -->
            </div>
        </section>
        <!-- Main content -->
        <!-- /.content -->
    </div>
@section JS{
    <script src="~/Content/AdminLTE/plugins/jQueryUI/jquery-ui.min.js"></script>
    <script>
        $(function () {
             $.ajax({
                 type: "get",
                 url: "/home/GetMessage",
                 dataType: "json",
                 data: {  },
                 success: function (data) {
                      if(data!=null&&data.list.length>0){
                            var $ul=$("#news_list");
                            $.each( data.list,function(i,value){
                                   if( value.type==4){
                                      $ul.append("<li><span class='handle'><i class='fa fa-cny text-yellow'></i></span><span >"+value.summary+"</span></li>");
                                   }
                                   else if(value.type==5){
                                      $ul.append("<li><span class='handle'><i class='fa fa-credit-card text-yellow'></i></span><span >"+value.summary+"</span></li>");
                                   }
                                   else{
                                      $ul.append("<li><span class='handle'><i class='fa fa-envelope text-yellow'></i></span><span >"+value.summary+"</span></li>");
                                   }
                            });
                       }
                       else{$("#news_list").append("<li><span >暂无消息</span></li>");}
                     }
             });
     });
    </script>
}